<%-- 
    Document   : index
    Author     : Jagadeesh
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.*" %>
<%@page import="model.UserBean" %>
<%@page import="database.DBClass"%>
<%@page import="validation.ValidateForm"%>
<%@ page import ="java.sql.*" %>
<% UserBean bean;
    bean = new UserBean();
    //get request from servlet if data is invalid

    if (request.getAttribute("error") != null) {
        bean = (UserBean) request.getAttribute("error");
    }
    if (request.getAttribute("updateuser") != null) {
        bean = (UserBean) request.getAttribute("updateuser");
    }
    

    if (session.getAttribute("user")== null ) {

                    RequestDispatcher rd = request.getRequestDispatcher("login.jsp");
                    rd.forward(request, response);
                }
%>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">

        <title>Information System Medcine</title>

        <!-- Bootstrap core CSS -->
        <link href="css/bootstrap.css" rel="stylesheet">

        <!-- Custom CSS for the '3 Col Portfolio' Template -->
        <link href="css/3-col-portfolio.css" rel="stylesheet">
    </head>
    <body>
    <nav class="navbar navbar-fixed-top navbar-inverse" role="navigation">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand">ISMED</a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse navbar-ex1-collapse">
                <ul class="nav navbar-nav">
                    <li><a href="home.jsp">Pencarian Obat</a></li>
                    <li><a href="#services">Pencarian Apotek</a></li>
                    <li><a href="login.jsp">Login Admin</a></li>

                </ul>
            </div><!-- /.navbar-collapse -->
        </div><!-- /.container -->
    </nav>

    <div class="container">

        <div class="row">

            <div class="col-lg-12">
                <h1 class="page-header">Insert Update Obat </h1>
            </div> 
            <script language="javascript" type="text/javascript">
                var xmlHttp
                var xmlHttp
                function showKabkota(str) {
                    if (typeof XMLHttpRequest != "undefined") {
                        xmlHttp = new XMLHttpRequest();
                    }
                    else if (window.ActiveXObject) {
                        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    if (xmlHttp == null) {
                        alert("Browser does not support XMLHTTP Request")
                        return;
                    }
                    var url = "kabkota.jsp";
                    url += "?count=" + str;
                    xmlHttp.onreadystatechange = stateChange;
                    xmlHttp.open("GET", url, true);
                    xmlHttp.send(null);
                }

                function stateChange() {
                    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
                        document.getElementById("kabkota").innerHTML = xmlHttp.responseText
                    }
                }

                function showKecamatan(str) {
                    if (typeof XMLHttpRequest != "undefined") {
                        xmlHttp = new XMLHttpRequest();
                    }
                    else if (window.ActiveXObject) {
                        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    if (xmlHttp == null) {
                        alert("Browser does not support XMLHTTP Request")
                        return;
                    }
                    var url = "kecamatan.jsp";
                    url += "?count=" + str;
                    xmlHttp.onreadystatechange = stateChange1;
                    xmlHttp.open("GET", url, true);
                    xmlHttp.send(null);
                }
                function stateChange1() {
                    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
                        document.getElementById("kecamatan").innerHTML = xmlHttp.responseText
                    }
                }

                function showDesa(str) {
                    if (typeof XMLHttpRequest != "undefined") {
                        xmlHttp = new XMLHttpRequest();
                    }
                    else if (window.ActiveXObject) {
                        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    if (xmlHttp == null) {
                        alert("Browser does not support XMLHTTP Request")
                        return;
                    }
                    var url = "desa.jsp";
                    url += "?count=" + str;
                    xmlHttp.onreadystatechange = stateChange2;
                    xmlHttp.open("GET", url, true);
                    xmlHttp.send(null);
                }
                function stateChange2() {
                    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
                        document.getElementById("desa").innerHTML = xmlHttp.responseText
                    }
                }
            </script> 
            <form method="post" action="ControllerServlet">
                <CENTER>
                    <TABLE border="0"width="600px">
                        <TR>
                            <TD width="150px">User Name:</TD>
                            <TD>
                                <INPUT TYPE="text" NAME="userName" value="<%=bean.getUserName()%>"
                            </TD>
                            <TD width="350px">
                                <font color="red"><%=bean.getUserNameError()%> &nbsp;</font>
                            </TD>
                        </TR>
                        <TR>
                            <TD width="150px">Nama</TD>
                            <TD>
                                <INPUT TYPE="text" NAME="email" value="<%=bean.getEmail()%>">
                            </TD>
                            <TD>
                                <font color="red"><%=bean.getEmailError()%> </font>
                            </TD>
                        </TR>
                        <TR>
                            <TD width="150px">Password:</TD>
                            <TD>
                                <INPUT TYPE="password" NAME="password" value="<%=bean.getPassword()%>">
                            </TD>
                            <TD>

                            </TD>
                        </TR>
                        <TR>
                            <TD colspan="2" align="center">
                                <INPUT TYPE="submit" value="<%=bean.getAction()%>" name="action">
                            </TD>
                            <TD>
                                &nbsp;
                            </TD>
                        </TR>
                    </TABLE>
                </CENTER>
            </form>
            </body>
            </html>
